#include <iostream>
#include <deque>
#include <list>
using namespace std;

int main(){ 
    list<int> lst = { 1, 2, 3, 4, 5, 6, 7, 8 };
    deque<int> dq1;
    deque<int> dq2;
    for (auto it = lst.begin(); it != lst.end(); it++){
        if (*it % 2){
            dq1.push_back(*it);
        } else {
            dq2.push_back(*it);
        }
    }

    for (auto elem : dq1){
        cout << elem << " ";
    }
    cout << endl;

    for (auto elem : dq2){
        cout << elem << " ";
    }
    cout << endl;
    return 0;
}